Skip to content

Conglomerated changes to optimize venv usage in pipeline #42486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

scbedd
Copy link
Member

@scbedd scbedd commented Aug 12, 2025

This PR:

  • Updates how we reference the virtual env that are installing all our base requirements into. We now support using uv to create this, with optional fallback to virtualenv.
  • Add a parameter InstallUv to use-venv.yml template. Defaults to true. When present, uv is installed, and variable $(PIP_EXE) is set to uv pip. If uv is not installed in this template, python -m pip will be set instead.
  • Use $(PIP_EXE) wherever we used to call python -m pip. So far I've gone through jobs/ci.yml and any template that is referenced from that for my update.
  • Remove an entire process of: set python 310, install azure-sdk-tools, and set tox environments. This script should run on any platform we support, so we moved it beneath the part of the template in build-tests.yml. Look for the yml around SetTestPipeline being moved.
  • Remove extraneous extra activation. The environment variables + path prepend are all that is required to properly have python recognize the venv. Proof in this test build

Impacts of using uv to improve install times are most visible here:

Job Old New
Build Linux 5m 45s 4m 53s
Build Windows 10m 6m 59s
Build MacOS 7m 19s 4m 45s

On average we're shaving ~1 minute or more off of each job.

@Copilot Copilot AI review requested due to automatic review settings August 12, 2025 19:29
@scbedd scbedd self-assigned this Aug 12, 2025
@scbedd scbedd moved this to 🔬 Dev in PR in Azure SDK EngSys 🍕 Aug 12, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request optimizes virtual environment usage in Azure DevOps pipelines by introducing UV (a fast Python package installer) as the preferred tool while maintaining fallbacks to traditional pip commands. The changes streamline environment setup and package installation across the build pipeline.

Key changes:

  • Integration of UV package manager with automatic fallback to pip when UV is unavailable
  • Simplified virtual environment activation by removing manual activation scripts in favor of environment variables
  • Addition of a new pipeline template for UV installation across different operating systems

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
eng/scripts/create-venv.ps1 Added UV detection and usage for virtual environment creation with fallback to virtualenv
eng/scripts/activate-venv.ps1 Simplified activation by setting VIRTUAL_ENV and PATH variables instead of sourcing activation scripts
eng/scripts/Language-Settings.ps1 Added UV pip usage for package installations with fallback logic
eng/pipelines/templates/steps/use-venv.yml Integrated UV installation template into virtual environment setup
eng/pipelines/templates/steps/seed-virtualenv-wheels.yml Replaced pip with UV for virtualenv installation
eng/pipelines/templates/steps/release-candidate-steps.yml Removed manual activation scripts and switched to UV for dependency installation
eng/pipelines/templates/steps/install-uv.yml New template for cross-platform UV installation
eng/pipelines/templates/steps/build-test.yml Simplified by removing activation scripts and using UV for package installation
eng/pipelines/templates/steps/build-package-artifacts.yml Updated to use UV and removed activation script dependencies
eng/pipelines/templates/steps/build-extended-artifacts.yml Switched from pip to UV for dependency installation
eng/pipelines/templates/steps/analyze.yml Replaced pip with UV for tool installation

@@ -8,8 +8,27 @@ parameters:
- name: Condition
type: string
default: succeeded()
- name: UseUv
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't currently set UseUv. So we can change this to default to false at any time and use bog-standard pip if we need to.

scbedd added 2 commits August 13, 2025 17:25
…lly remove a UsePython3.10 + install build tooling + SetTestPipeline + SetToxTargets. none of those are python 3.10 specific and can be moved to run on the same python version that is running in the build
@scbedd
Copy link
Member Author

scbedd commented Aug 13, 2025

/azp run python - core

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scbedd
Copy link
Member Author

scbedd commented Aug 13, 2025

Kicked python - core for full environment test, and here is a livetest run to ensure livetests are not broken by this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔬 Dev in PR
Development

Successfully merging this pull request may close these issues.

1 participant